package com.hujf.flink.DataSet;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.ReduceOperator;
import org.apache.flink.api.java.tuple.Tuple3;

/**
 * @Author hujf
 * @Date 2022/5/19 10:22
 * @Description TODO
 */
public class MinByTest {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();

        DataSet<Tuple3<Integer, Integer, Integer>> tuple2DataSource = environment.fromElements(new Tuple3<>(2,2,3), new Tuple3<>(3, 2,3),new Tuple3<>(2,2,1));

        ReduceOperator<Tuple3<Integer, Integer, Integer>> tuple3ReduceOperator = tuple2DataSource.groupBy(1)
                .minBy(0, 2);

        tuple3ReduceOperator.print();
    }
}
